Ninja Database Lite
Using Compression
Basic Tasks > Using Compression

Ninja Database Lite has the ability to compress and decompress data by simply setting the config.Format property.

 

Example in C#:

 

NinjaDbConfig config = new NinjaDbConfig();

string databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FileStorageTestsNinjaDb");

config.Storage = new FileDatabase(databasePath);

config.Format = EncodingFormat.GZipCompressed;

 

NinjaDb ninja = new NinjaDb(config);

Person person = new Person();

person.Name = "John";

person.PersonId = 1;

 

//Save

ninja.Save("Person1", person);

 

//Get Keys

List<string> keys = ninja.GetKeys();

 

//Load

Person personCopy = ninja.Load<Person>("Person1");

 

 

Example in VB.NET

 

Dim config As New NinjaDbConfig()

Dim databasePath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FileStorageTestsNinjaDb")

config.Storage = New FileDatabase(databasePath)

config.Format = EncodingFormat.GZipCompressed

Dim ninja As New NinjaDb(config)

 

Dim person As New Person()

person.Name = "John"

person.PersonId = 1

 

'Save

ninja.Save("Person1", person)

 

'Get Keys

Dim keys As List(Of String) = ninja.GetKeys()

 

'Load

Dim personCopy As Person = ninja.Load(Of Person)("Person1")